package com.liujing.tacticspatten;

/**
 * @program: DesignPattenDemo
 * @description: 测试类
 * @author: liujing
 * @create: 2019-11-22 11:13
 **/
public class Test {
    public static void main(String[] args) {
        /*
          简单工厂模式需要客户端认识两个类CashFactory及CashSuper两个类
         */
        CashSuper cashSuperNormal = CashFactory.createCashAccept("正常收费");
        double totalPriceNormal = cashSuperNormal.acceptCash(100);
        System.out.println("简单工厂模式-正常收费：" + totalPriceNormal);

        CashSuper cashSuperRebate = CashFactory.createCashAccept("打8折");
        double totalPriceRebate = cashSuperRebate.acceptCash(100);
        System.out.println("简单工厂模式-打8折：" + totalPriceRebate);

        CashSuper cashSuperReturn = CashFactory.createCashAccept("满300减100");
        double totalPriceReturn = cashSuperReturn.acceptCash(600);
        System.out.println("简单工厂模式-满300减100：" + totalPriceReturn);
        System.out.println("******************************************");

        /*
            策略模式客户端只需要认识一个类CashContext就可以
         */
        //策略模式-正常收费,"满300减100","打8折"
        System.out.println("策略+简单工厂模式-正常收费：" + new CashContext("正常收费").getResult(100));
        System.out.println("策略+简单工厂模式-打8折：" + new CashContext("打8折").getResult(100));
        System.out.println("策略+简单工厂模式-满300减100：" + new CashContext("满300减100").getResult(300));

    }
}
